<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="robots" content="index,follow">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <meta name="renderer" content="ie-stand">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
    <meta name="format-detection" content="telephone=no">
    <title>登录</title>
    <link rel="stylesheet" href="<?=IMG_URL?>apps/m_oa/css/myreset.css" />
    <link rel="stylesheet" href="<?=IMG_URL?>apps/m_oa/css/iconfont.css" />
    <link rel="stylesheet" href="<?=IMG_URL?>apps/m_oa/css/m.gd.css" />
    <script src="<?=IMG_URL?>apps/m_oa/js/ResetFontSize.js"></script>
</head>
<body>
<div class="login">
    <a href="javascript:;" class="logo">
        <img src="<?=IMG_URL?>apps/m_oa/images/logo.png" />
        <span>融媒体</span>
    </a>
    <form class="lgnForm">
        <div class="formLi">
                <span>
                    <i class="iconfont icon-user1"></i>
                    <input type="text" name="uname" value="" placeholder="用户名" />
                    <i class="iconfont icon-close"></i>
                </span>
        </div>
        <div class="formLi">
                <span>
                    <i class="iconfont icon-lock"></i>
                    <input type="password" name="upass" value="" placeholder="密码" />
                    <input type="text" value="upass" placeholder="密码" style="display: none">
                    <i class="iconfont icon-eye"></i>
                </span>
        </div>
        <div class="TipLi">
            <div class="checkbox">
                <input type="checkbox" class="allChk" />
                <label>记住密码</label>
            </div>
        </div>
        <a href="javascript:;" class="lgnBtn subSave">登录</a>
        <!--<a href="javascript:;" class="regBtn">注册</a>-->
    </form>
</div>
<script src="<?=IMG_URL?>apps/m_oa/js/rsa/Barrett.js"></script>
<script src="<?=IMG_URL?>apps/m_oa/js/rsa/RSA.js"></script>
<script src="<?=IMG_URL?>apps/m_oa/js/rsa/BigInt.js"></script>
<script type="text/javascript" src="<?=IMG_URL?>apps/m_oa/js/jquery-3.js"></script>
<script type="text/javascript" src="<?=IMG_URL?>apps/m_oa/js/form.js"></script>
<script src="<?=IMG_URL?>apps/oa/js/layer/layer.js"></script>

<script type="text/javascript">
    //控制 清空图标 显示和隐藏
    $('.lgnForm').on('keyup','input',function(){
        var p = $(this).parents('.formLi'),
            i = $(p).find('i.icon-close'),
            v = $(this).val();
        if(v != ''){
            $(i).css('display','block')
        }else{
            $(i).css('display','none');
        }
    })
    //清空图标点击事件
    $('.lgnForm').on('click','i.icon-close',function(){
        var p = $(this).parents('span'),
            inp = $(p).find('input');
        $(inp).val('');
        $(this).css('display','none');
        $(this).formTip('right')
    })
    //密码显隐点击事件
    $('.lgnForm').on('click','.icon-eye',function(){
        var p = $(this).parents('span'),
            inp = $(p).find('input');
        if($(p).hasClass('Ac')){
            var str = $(inp).eq(1).val();
            $(inp).eq(0).val(str).css('display','block');
            $(inp).eq(1).css('display','none');
            $(p).removeClass('Ac')
        }else{
            var str = $(inp).eq(0).val();
            $(inp).eq(1).val(str).css('display','block');
            $(inp).eq(0).css('display','none');
            $(p).addClass('Ac')
        }
    })
    //表单校验
    var is_click = true;
    $('.lgnForm').verify({
        lineClass:'formli',
        errorClass:'error',
        fileds:{
            uname:{
                notEmpty:'用户名不能为空!',
                ajax:[{
                    fn:function(str){
                        var flag = true,
                            reg = /^\d+$/;
                        if(reg.test(str)){
                            reg = /(13|14|15|17|18|19)[0-9]{9}/;
                            if(reg.test(str)){
                                flag = true;
                            }
                        }
                        return flag;
                    },
                    txt:'电话号码格式错误!'
                }]
            },
            upass:{
                notEmpty:'请输入密码!'
            }
        }
    },function(flag){//flag为true时表示以上校验都正确， 为false表示校验有错 一下逻辑自行添加
        if(flag&&is_click){
            is_click = false;
            layer.msg('正在登录,请稍后...',{time:10*1000000});
           var username =  $("input[name='uname']").val().trim();
           var password = $("input[name='upass']").val().trim();
           var $APP_RSA_MODULUS =
                "c59c517f8b8446fa509e283039acba8b07c00902e9"+
                "900df85d6e474c296cce8725b7aaf3d4a7010e6b3d318faf0cceddc366533c4289867f8a7150cc77"+
                "26d5f47966bad7756c71d48ac17d1082617cfc2d6dc7c5c9dd8c1dc4c51495f629509408be168684266"+
                "38358e82d2e567bfa4a14211de5d97d30f6256eef3a8a66fa75";
           var $APP_RSA_EXPONENT = "10001";
           // console.log($APP_RSA_MODULUS,$APP_RSA_EXPONENT);
            setMaxDigits(129);
            var key = new RSAKeyPair($APP_RSA_EXPONENT,"", $APP_RSA_MODULUS);
            username = encodeURIComponent(username);
            password = encodeURIComponent(password);
            username = username.split("").reverse().join("");
            username = encryptedString(key,username);
            password = password.split("").reverse().join("");
            password = encryptedString(key,password);
            $.ajax({
               'url':'/c_oa/public/app/?app=oa&controller=m_login&action=login',
               'type':'get',
               'dataType':'json',
               'data':{username:username,password:password },
               'success':function (res) {
                   is_click = true;
                   if(res.code==0){
                       layer.msg(res.msg);
                   }
                   else {
                       layer.msg('登录成功！');
                       window.location.href = '/c_oa/public/app/?app=oa&controller=m_index&action=index';
                   }
               }
           });
        }
    })

    // function testAPI(obj) {
    //     setMaxDigits(130);
    //     var publicKey = new RSAKeyPair(API_CONFIG.PUBLIC_KEY_EXPONENT, "", API_CONFIG.PUBLIC_KEY_MODULUS);
    //     var para = getCommonParameter();
    //     var frm = $(obj).parent().parent();
    //     var tab = $("table.fullwidth", frm);
    //     var rows = $(".operation-params", tab).find("tr");
    //     rows.each(function(index, row) {
    //         //如果有行合并就说明是子类了，不加入参数
    //         if($("td:eq(0)", row).attr("colspan")) return false;
    //         var key = $("td:eq(0)", row).text();
    //         var value = $("td:eq(1)", row).find("input[name='PARAMETER_VALUE']").val();
    //         var rsa = $("td:eq(1)", row).find("input[name='PARAMETER_RSA']").val();
    //         value = encodeURIComponent(value);
    //         if(rsa == "Y") {
    //             value = value.split("").reverse().join("");  //JavaScript RSA会倒序，所以先这边倒序处理
    //             //alert(value);
    //             value = encryptedString(publicKey, value);
    //         }
    //         para[key] = value;
    //     });
    //     para = sign(para);
    //     var keyvalue = buildParameter(para);
    //     //alert(JSON2.stringify(para));
    //     var url = "" + window.location.protocol + "//" + window.location.host + contextPath + API_CONFIG.PREFIX_URI
    //     var li = $(obj).closest("li.operation");
    //     var path = url + $("span.path", li).find("a").text();
    //
    //     $("div.request_url", li).find("pre").text(path + "?" + keyvalue);
    //
    //     if($("p.dataType", li).text() == "JSON") {
    //         var responseBody = $("div.response_body", li).find("code");
    //         var responseHeaders = $("div.response_headers", li).find("pre");
    //         responseBody.text("请求中...");
    //         var bgnDate = new Date();
    //         $.ajax({
    //             type: "POST",
    //             url: path,
    //             data: para,
    //             dataType: 'json',
    //             success: function(result) {
    //                 var endDate = new Date();
    //                 responseHeaders.text("响应时间:" + (endDate.getTime() - bgnDate.getTime()) + "ms");
    //                 responseBody.text(JSON2.stringify(result, null, 4));
    //                 //alert(JSON2.stringify(result));
    //             },
    //             error: function(XMLHttpRequest, textStatus, errorThrown) {
    //                 if(XMLHttpRequest.status == 404) {
    //                     responseBody.text("接口不存在");
    //                 } else {
    //                     responseBody.text("status:" + XMLHttpRequest.status + "\nreadyState:" + XMLHttpRequest.readyState);
    //                 }
    //             }
    //         });
    //     } else {
    //         window.open(path + "?" + keyvalue, "_blank", "");
    //     }
    // }
</script>
</body>
</html>